//
// Created on 2024/7/31.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be
// found, please include "napi/native_api.h".

#ifndef ARKUI_C_API_ARKUITEXTNODE_H
#define ARKUI_C_API_ARKUITEXTNODE_H

#include "src/ArkUINode.h"
#include <string>

namespace NativeModule {

class ArkUITextNode : public ArkUINode {
public:
    ArkUITextNode()
        : ArkUINode(NativeModuleInstance::getInstance()->GetNativeNodeAPI()->createNode(
              ARKUI_NODE_TEXT)) {}

    void SetFontSize(float fontSize) {
        assert(handle_);
        ArkUI_NumberValue value[] = {{.f32 = fontSize}};
        ArkUI_AttributeItem item = {value, 1};
        nativeModule_->setAttribute(handle_, NODE_FONT_SIZE, &item);
    }

    void SetFontColor(uint32_t color) {
        assert(handle_);
        ArkUI_NumberValue value[] = {{.u32 = color}};
        ArkUI_AttributeItem item = {value, 1};
        nativeModule_->setAttribute(handle_, NODE_FONT_COLOR, &item);
    }

    void SetTextContent(const std::string &content) {
        assert(handle_);
        ArkUI_AttributeItem item = {nullptr, 0, content.c_str()};
        nativeModule_->setAttribute(handle_, NODE_TEXT_CONTENT, &item);
    }

    void SetTextAlign(ArkUI_TextAlignment align) {
        assert(handle_);
        ArkUI_NumberValue value[] = {{.i32 = align}};
        ArkUI_AttributeItem item = {value, 1};
        nativeModule_->setAttribute(handle_, NODE_TEXT_ALIGN, &item);
    }
};

} // namespace NativeModule

#endif // ARKUI_C_API_ARKUITEXTNODE_H
